# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gtksourceview
pkgbase=mingw-w64-${_realname}3
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}3"
pkgver=3.24.11
pkgrel=4
pkgdesc="A text widget adding syntax highlighting and more to GNOME (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.gnome.org"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "intltool")
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libxml2")
source=("https://download.gnome.org/sources/gtksourceview/${pkgver%.*}/gtksourceview-${pkgver}.tar.xz"
        0001-gtksourceview3-remove-comment-mkenums.patch)
sha256sums=('691b074a37b2a307f7f48edc5b8c7afa7301709be56378ccf9cc9735909077fd'
            'feb1249bd7804adf4ac67ffea15f9630aff110e9820a1d4af7922f1eb19a95df')

prepare() {
  cd ${_realname}-${pkgver}

  # workaround: glib-mkenums adds wrong comments in gtksourceview-enumtypes.c
  patch -p1 -i "${srcdir}/0001-gtksourceview3-remove-comment-mkenums.patch"

  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}"
  cd "${srcdir}/build-${MSYSTEM}"

  mkdir -p docs/reference/html
  cp -rf ../${_realname}-${pkgver}/docs/reference/html/* docs/reference/html

  # workaround warning: linker path does not have real file for library -luuid.
  export lt_cv_deplibs_check_method='pass_all'

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --disable-glade-catalog \
    --disable-gtk-doc

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make -j1 DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
